package lattice;

import java.util.ArrayList;

import lattice.traveler.SyncedStateCut;

public class ConsistentStates {
	private SyncedStateCut sec = new SyncedStateCut(); // version numbers of the data in the consistent states
	private ArrayList<Object> sDat = new ArrayList(); // data of shared objects
	
	/**
	 * Returns the version number of a specific state
	 * @param sid state id
	 * @return version number of the state
	 */
	public int getVN(int sid) {
		return sec.getVid(sid);
	}
	
	/**
	 * Replace the SyncedStateCut of current ConsistentStates
	 * @param sec new version numbers for current consistent states
	 */
	//public void setSEC(SyncedStateCut sec) {
	//	this.sec = sec;
	//}
	
	/**
	 * Returns the specific state
	 * @param sid state id
	 * @return the specific state
	 */
	public Object getState(int sid) {
		return sDat.get(sid);
	}
	
	/**
	 * Append a state and it's version number
	 * @param vn version number of the state
	 * @param obj state of a shared object
	 */
	public void addState(int vn, Object dat) {
		sec.addVid(vn);
		sDat.add(dat);
	}
	
	@Override
	public String toString() {
		return sec.toString();
	}
}
